package cn.blnp.net.flowable.config;

import cn.blnp.net.flowable.consumer.ConProcessor;
import cn.blnp.net.flowable.consumer.ResultProcessor;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * <h3>Camel自定义路由配置</h3>
 *
 * @author <a href="mailto:blnp.yibin@qq.com">lyb</a>
 * @version 1.0
 * @since 2025/5/14 10:14
 */
@Configuration
public class MyCamelRoutes extends RouteBuilder {

    @Resource
    private ConProcessor conProcessor;

    @Override
    public void configure() throws Exception {
        //from("direct:start")
        //        .to("log:Message received")
        //        .process(conProcessor)
        //        /**
        //         *  参数说明：
        //         *  flowable 协议开头，指向工作流引擎端点
        //         *  CamelTaskProcess    流程定义key
        //         *  camelTask1  流程定义中Camel任务的ID
        //         *  username=baby 路由URI的参数
        //         **/
        //        .from("flowable:CamelTaskProcess:camelTask1?username=baby")
        //        .to("log:org.flowable.camel.examples.SimpleCamelCall")
        //;

        //案例演示规则
        from("flowable:camelTaskProcess:camelTask1?copyVariablesToProperties=true")
                .toD("http://whois.pconline.com.cn/ipJson.jsp?ip=${exchange.properties[ip]}&json=true")
                .process(new ResultProcessor());
    }
}
